package com.ddone.app.demo;

import com.ddone.util.LocalFileReaderUtil;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @author ddone
 * @date 2024/5/29-13:43
 */
public class FlinkCDCSqlDemoWithConfigApp {
    public static void main(String[] args) throws Exception {
        // TODO 1. 准备环境
        // 1.1 流处理环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        // 1.2 表执行环境
        StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);

        // TODO 2. 创建动态表
        String sql = LocalFileReaderUtil.getResourceFileContent("sql/user_info-load.sql");
        tableEnv.executeSql(sql.split(";")[0]);
        tableEnv.executeSql(sql.split(";")[1]).print();
        // TODO 3. 执行任务
        env.execute();
    }
}
